<script setup>
import { RouterLink, RouterView } from 'vue-router'
import { useQiankun } from '@/utils/qiankun'

// 获取应用信息
const appInfo = useQiankun()
</script>

<template>
  <div class="app-container">
    <!-- 应用标题栏 -->
    <div class="app-title">
      <h2>子应用2 (qiankun-zi02)</h2>
      <el-tag :type="appInfo.isSubApp ? 'success' : 'warning'" size="large">
        {{ appInfo.appType.toUpperCase() }}
      </el-tag>
    </div>

    <header>
      <img alt="Vue logo" class="logo" src="@/assets/logo.svg" width="80" height="80" />

      <div class="wrapper">
        <nav>
          <RouterLink to="/">主应用交互演示</RouterLink>
          <RouterLink to="/home">首页</RouterLink>
          <RouterLink to="/about">关于</RouterLink>
        </nav>
      </div>
    </header>

    <main>
      <RouterView />
    </main>

    <!-- 应用信息栏 -->
    <footer class="app-footer">
      <p>
        应用类型: <strong>{{ appInfo.appType }}</strong> | 
        运行环境: <strong>{{ appInfo.isSubApp ? '微前端模式' : '独立模式' }}</strong>
      </p>
    </footer>
  </div>
</template>

<style scoped>
.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.app-title h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

header {
  line-height: 1.5;
  padding: 20px;
  background: #fafbfc;
  border-bottom: 1px solid #e4e7ed;
}

.logo {
  display: block;
  margin: 0 auto 1rem;
}

nav {
  width: 100%;
  font-size: 14px;
  text-align: center;
  margin-top: 1rem;
}

nav a.router-link-exact-active {
  color: #409eff;
  background-color: #ecf5ff;
  border-color: #409eff;
}

nav a.router-link-exact-active:hover {
  background-color: #409eff;
  color: white;
}

nav a {
  display: inline-block;
  padding: 8px 16px;
  margin: 0 5px;
  border: 1px solid #dcdfe6;
  border-radius: 4px;
  text-decoration: none;
  color: #606266;
  transition: all 0.3s;
}

nav a:hover {
  background-color: #409eff;
  color: white;
  border-color: #409eff;
}

main {
  flex: 1;
  padding: 20px;
}

.app-footer {
  padding: 15px 20px;
  background: #f5f7fa;
  border-top: 1px solid #e4e7ed;
  text-align: center;
  color: #909399;
  font-size: 14px;
}

.app-footer strong {
  color: #303133;
}

@media (min-width: 1024px) {
  header {
    display: flex;
    place-items: center;
    padding: 20px 40px;
  }

  .logo {
    margin: 0 2rem 0 0;
  }

  header .wrapper {
    display: flex;
    place-items: flex-start;
    flex-wrap: wrap;
    width: 100%;
  }

  nav {
    text-align: left;
    font-size: 16px;
    margin-top: 0;
  }
}
</style>
